#include <bits/stdc++.h>
using namespace std;
map<int,int> mp;
int main()
{
  int n,x;
  cin >> n;
  while(n--){
    cin >> x;
    mp[x]++;
    mp[x-1]++;
    mp[x+1]++;
  }
  int max = 0;
  for(const auto& a:mp){
    if(a.second> max)max = a.second;
  }
  cout << max;
  return 0;
}
